<?php $this->beginBlock('block_nav'); ?>
<li><a href="/report/shop-sale">门店销售统计</a></li>
<li><a href="/report/shop-product-sale">销售产品明细</a></li>

<?php $this->endBlock(); ?>




<?php $this->beginBlock('block_script'); ?>
<script type="text/javascript">

    $(function () {

        //Date picker
        $('.form_datetime').datepicker({
            autoclose: true,
            format: 'yyyy-mm-dd',
            language: 'zh-CN',
            todayBtn: 'linked',
            initialDate: new Date(),
            endDate: new Date()

        });


        $("#btn_submit").click(function () {
            var $btn = $(this).button('loading');
            $("#div_content").empty();
            var form = $('#form_search').serialize();


            $.post('/report/shop-product-sale',form,function(data){
                $btn.button('reset');
                if(data.code == 200){
                    viewHandle.showResult(data.data);
                }else{
                    alertError(data.msg);
                }

            },'json');

        });


    })


    var viewHandle = {
        showResult: function (shops) {


            $.each(shops,function (i,shop) {
                var html = '<div class="box box-danger">';
                html += '<div class="box-header with-border">';
                html += '<i class="fa fa-inbox"></i>';
                html += '<h3 class="box-title">'+shop.shopName+'</h3>';
                html += '</div>';
                html += '<div class="box-body">';
                html += '<div class="table-responsive">';
                html += '<table class="table table-striped">';
                html += '<thead>';
                html += '<tr>';
                html += '<th>分类</th>';
                html += '<th>品名</th>';
                html += '<th>小计</th>';
                html += '<th>单点</th>';
                html += '<th>套餐</th>';
                html += '</tr>';
                html += '</thead>';
                html += '<tbody>';
                $.each(shop.productSale,function (j,sale) {
                    html += '<tr><td>'+sale.name+'</td><td>'+sale.product_name+'</td><td>'+sale.qty_total+'</td><td>'+sale.qty_single+'</td><td>'+sale.qty_comb+'</td></tr>';
                });
                html += '</tbody>';
                html += '</table>';
                html += '</div>';
                html += '</div>';
                html += '</div>';
                $("#div_content").append(html);
            });


        }


    }



</script>
<?php $this->endBlock(); ?>


<?php $this->beginContent('@app/views/layouts/adminlte_comm.php'); ?>
<section class="content-header">
    <h1>
        销售产品明细
        <small>单店单日内部销售产品明细查询</small>
    </h1>
</section>

<!-- Main content -->
<section class="content">
    <div class="row">
        <!-- left column -->
        <div class="col-md-12">
            <!-- general form elements -->
            <div class="box">
                <!-- /.box-header -->
                <!-- form start -->
                <form role="form" id="form_search">
                    <div class="box-body">
                        <input type="text" class="form-control pull-right form_datetime" id="start_date" name="start_date" placeholder="开始日期" readonly>
                        <input type="text" class="form-control pull-right form_datetime" id="end_date" name="end_date" placeholder="结束日期" readonly>

                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="button" class="btn btn-danger pull-right" data-loading-text="Loading..." id="btn_submit">确定</button>
                    </div>
                </form>
            </div>
            <!-- /.box -->
            <div id="div_content">

            </div>


        </div>

    </div>


</section>
<!-- /.content -->

<?php $this->endContent(); ?>



